package com.logistics.map.entity.model;

import com.logistics.map.entity.domain.MapComponents;
import com.logistics.map.entity.domain.MapRouteNodes;
import com.logistics.utils.aspect.annotation.Dictionary;
import com.logistics.utils.tool.DateUtils;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class MapComponentsRow extends MapRouteNodesRow{

    private Integer id;
    private Integer mapId;
    private String clazz;
    private String color;
    private String uuid;
    private String label;
    private String size;
    private String type;
    private String locationArea;
    private String x;
    private String y;
    private String routeCode;
    private Integer containerId;
    @Dictionary(key="car_type")
    private String agvType;
    private String remark;
    private String workshop;
    private String location;
    private String deviceId;
    private String locationWcCode;
    @Dictionary(key="location_lock_status")
    private String locationLock;
    private Integer currentStratum;
    private BigDecimal locationHeight;
    @Dictionary(key ="location_zone")
    private String zone;
    private String relayWcCode;
    @Dictionary(key = "container_type")
    private String containerType;
    private String createOrgCode;
    private String createDepCode;
    private String creator;
    private String createTime;
    private String updater;
    private String updateTime;
    //lgs_qrcode name
    private String name;

    public MapComponentsRow(){}

    public MapComponentsRow(MapComponents mapComponents){
        this.id =  mapComponents.getId();
        this.mapId = mapComponents.getMapId();
        this.clazz = mapComponents.getClazz();
        this.color = mapComponents.getColor();
        this.uuid = mapComponents.getUuid();
        this.label = mapComponents.getLabel();
        this.size = mapComponents.getSize();
        this.type = mapComponents.getType();
        this.locationArea = mapComponents.getLocationArea();
        this.x = StringUtils.isNotNull(mapComponents.getX())?mapComponents.getX().toString():"";
        this.y = StringUtils.isNotNull(mapComponents.getY())?mapComponents.getY().toString():"";
        this.routeCode = mapComponents.getRouteCode();
        this.containerId = mapComponents.getContainerId();
        this.agvType = mapComponents.getAgvType();
        this.remark = mapComponents.getRemark();
        this.workshop = mapComponents.getWorkshop();
        this.location = mapComponents.getLocation();
        this.deviceId = mapComponents.getDeviceId();
        this.locationWcCode = mapComponents.getLocationWcCode();
        this.locationLock = StringUtils.isNotNull(mapComponents.getLocationLock()) ? (mapComponents.getLocationLock() ? "1" :"0") : "0";
        this.currentStratum = mapComponents.getCurrentStratum();
        this.locationHeight = mapComponents.getLocationHeight();
        this.zone = mapComponents.getZone();
        this.relayWcCode = mapComponents.getRelayWcCode();
        this.containerType = mapComponents.getContainerType();
        this.name = mapComponents.getName();
        this.createOrgCode = mapComponents.getCreateOrgCode();
        this.createDepCode = mapComponents.getCreateDepCode();
        this.creator = mapComponents.getCreator();
        this.createTime = DateUtils.dateToStringFormat(mapComponents.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = mapComponents.getUpdater();
        this.updateTime = DateUtils.dateToStringFormat(mapComponents.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public MapComponentsRow(MapRouteNodes nodes){
        this.clazz = nodes.getClazz();
        this.uuid = nodes.getUuid();
        this.type = nodes.getType();
        this.x = StringUtils.isNotNull(nodes.getX()) ? nodes.getX().toString() : "";
        this.y = StringUtils.isNotNull(nodes.getY()) ? nodes.getY().toString() : "";
        this.setRouteCode(nodes.getRouteCode());
    }

    public static MapComponentsRow build(MapComponents mapComponents){
        return new MapComponentsRow(mapComponents);
    }

    public static MapComponentsRow build(MapRouteNodes nodes){
        return new MapComponentsRow(nodes);
    }
}
